﻿using System;
using System.ServiceModel;
using Microsoft.ServiceModel.Web;
using Spring.ServiceModel.Activation;
using Acaweb.Services.Security.Interceptors;

namespace Acaweb.Services.Security
{
    public class AcawebServiceFactory : ServiceHostFactory
    {
        protected override ServiceHost CreateServiceHost(Type serviceType, Uri[] baseAddresses)
        {
            WebServiceHost2 result = new WebServiceHost2(serviceType, true, baseAddresses);

            result.Interceptors.Add(new BasicAuthenticationInterceptor(null, "Iniciar Sesion"));

            return result;
        }
    }

    public class UnsecureServiceFactory : ServiceHostFactory
    {
        protected override ServiceHost CreateServiceHost(Type serviceType, Uri[] baseAddresses)
        {
            WebServiceHost2 result = new WebServiceHost2(serviceType, true, baseAddresses);           
            return result;
        }
    }
}